﻿using System;
using System.Collections.Generic;
using System.Text;
using Lottery.App.Model;

namespace Lottery.App.DAL
{
    public class A2Dao : ResultDao<A2Info>
    {
        protected override IList<A2Info> GetItems(RecordInfo record)
        {
            List<string> array = Utility.Utils.GetA2(record.Result);

            string hql = "from A2Info where Value in (:val)";

            return Session.CreateQuery(hql)
                .SetParameterList("val", array)
                .List<A2Info>();
        }

        protected override int GetLastID(string value)
        {
            string hql = "select Max(r.id) from RecordInfo r where Result like ?";

            return Session.CreateQuery(hql)
                .SetString(0, MatchMode.Anywhere(value))
                .UniqueResult<int>();
        }

        internal override IList<RecordInfo> List(string value)
        {
            string hql = "from RecordInfo where Result like ?";

            return Session.CreateQuery(hql)
                .SetString(0, MatchMode.Anywhere(value))
                .List<RecordInfo>();
        }

        public override IList<int> GetIds(string value)
        {
            string hql = "select r.id from RecordInfo r where Result like ?";

            return Session.CreateQuery(hql)
                .SetString(0, MatchMode.Anywhere(value))
                .List<int>();
        }

        
    }
}
